{% extends "admin/change_list.html" %}
{% load i18n admin_urls static %}

{% block extrastyle %}
    {{ block.super }}
    <style>
        .export-btn {
            display: inline-block;
            padding: 6px 12px;
            margin-bottom: 0;
            font-size: 12px;
            font-weight: 400;
            line-height: 1.42857143;
            text-align: center;
            white-space: nowrap;
            vertical-align: middle;
            cursor: pointer;
            background-color: #1890ff;
            border: 1px solid transparent;
            border-radius: 4px;
            color: #fff;
            text-decoration: none;
        }
        .export-btn:hover {
            background-color: #40a9ff;
            color: #fff;
            text-decoration: none;
        }
        .object-tools {
            margin-top: -32px;
        }
    </style>
{% endblock %}

{% block object-tools %}
    <ul class="object-tools">
        {% block object-tools-items %}
            {{ block.super }}
        {% endblock %}
    </ul>
{% endblock %}

{% block content %}
    {{ block.super }}
    <script>
        (function($) {
            $(document).ready(function() {
                // 为每一行添加导出按钮
                $('#result_list tbody tr').each(function() {
                    var row = $(this);
                    var id = row.find('th input[type=checkbox]').val();
                    if (id) {
                        var exportUrl = "{% url 'admin:api_manager_testreport_export_pdf' 999999 %}".replace('999999', id);
                        row.append(
                            '<td><a href="' + exportUrl + '" class="export-btn" title="导出PDF报告">导出PDF</a></td>'
                        );
                    }
                });
                
                // 添加操作列标题
                $('#result_list thead tr').append('<th scope="col">操作</th>');
            });
        })(django.jQuery);
    </script>
{% endblock %} 